import Vue from 'vue'
import VueRouter from 'vue-router'
import Layout from '@/layout/index'
import {
	Form
} from 'element-ui'
const VueRouterPush = VueRouter.prototype.push
VueRouter.prototype.push = function push(to) {
	return VueRouterPush.call(this, to).catch(err => err)
}
Vue.use(VueRouter)
const routes = [{
	path: '/',
	redirect: '/index'
	/* }, {
		path: '/login',
		name: 'Login',
		component: () => import('@/views/login.vue')
	}, {
		path: '/register',
		name: 'Register',
		component: () => import('@/views/register.vue') */
}, {
	path: '/404',
	name: '404',
	component: () => import('@/views/404.vue')
}, {
	path: '/main',
	name: 'main',
	meta: {
		title: '首页'
	},
	redirect: '/index',
	component: Layout,
	children: [{
		path: '/index',
		name: 'indexIndex',
		meta: {
			title: "首页",
			showCrumb: false
		},
		component: () => import('@/views/index/index')
	}, {
		path: '/regulation',
		name: 'Regulation',
		meta: {
			title: '政策法规'
		},
		redirect: '/regulation/list',
		component: () => import('@/views/common/router'),
		children: [{
			path: '/regulation/list',
			name: 'regulationList',
			meta: {
				title: '政策法规列表',
				isDetail: true
			},
			component: () => import('@/views/regulation/list')
		}, {
			path: '/regulation/list/:id',
			name: 'regulationDetail',
			meta: {
				title: '政策法规详情',
				isDetail: true
			},
			component: () => import('@/views/regulation/detail')
		}]
	}, {
		path: '/message',
		name: 'Message',
		meta: {
			title: '首长信箱'
		},
		component: () => import('@/views/message/index')
	}, {
		path: '/model',
		name: 'Model',
		meta: {
			title: '先进典型'
		},
		component: () => import('@/views/model/index')
	}, {
		path: '/model/:id',
		name: 'ModelDetail',
		meta: {
			title: '先进典型详情',
			isDetail: true
		},
		component: () => import('@/views/model/detail')
	}, {
		path: '/journal',
		name: 'Journal',
		meta: {
			title: '天天读报'
		},
		component: () => import('@/views/journal/index')
	}, {
		path: '/books',
		name: 'Books',
		meta: {
			title: '书香军营'
		},
		redirect: '/books/list',
		component: () => import('@/views/books/index'),
		children: [{
			path: '/books/list',
			name: 'bookList',
			meta: {
				title: '好书推荐'
			},
			component: () => import('@/views/books/list')
		}, {
			path: '/books/:id',
			name: 'bookDetail',
			hidden: true,
			meta: {
				title: '书籍详情',
				isDetail: true,
				bgColor: '#f7f7f7'
			},
			component: () => import('@/views/books/detail')
		}]
	}, {
		path: '/sharing',
		name: 'Sharing',
		meta: {
			title: '分享交流'
		},
		component: () => import('@/views/sharing/list')
	}, {
		path: '/sharing/:id',
		name: 'sharingDetail',
		meta: {
			title: '分享交流详情'
		},
		component: () => import('@/views/sharing/detail')
	}, {
		path: '/study',
		name: 'Study',
		meta: {
			title: '学习天地'
		},
		redirect: '/study/history',
		component: () => import('@/views/study/index'),
		children: [{
			path: '/study/history',
			name: 'studyHistory',
			meta: {
				title: '党史学习'
			},
			component: () => import('@/views/study/history')
		}, {
			path: '/study/course',
			name: 'studyCourse',
			meta: {
				title: '党课教育'
			},
			component: () => import('@/views/study/course')
		}, {
			path: '/study/training',
			name: 'studyTraining',
			meta: {
				title: '党务培训'
			},
			component: () => import('@/views/study/training')
		}]
	}, {
		path: '/news',
		name: 'News',
		meta: {
			title: '仓库动态'
		},
		redirect: '/news/office',
		component: () => import('@/views/news/index'),
		children: [{
			path: '/news/office',
			name: 'newsOffice',
			meta: {
				title: '机关动态'
			},
			component: () => import('@/views/news/office')
		}, {
			path: '/news/base',
			name: 'newsBase',
			meta: {
				title: '基层动态'
			},
			component: () => import('@/views/news/base')
		}, {
			path: '/news/:type/:id',
			name: 'newsDetail',
			hidden: true,
			meta: {
				title: '新闻动态详情',
				isDetail: true
			},
			component: () => import('@/views/news/detail')
		}]
	}, {
		path: '/bbs',
		name: 'Bbs',
		meta: {
			title: '强军论坛'
		},
		redirect: '/bbs/technology',
		component: () => import('@/views/bbs/index'),
		children: [{
			path: '/bbs/technology',
			name: 'bbsTechnology',
			meta: {
				title: '前沿科技'
			},
			component: () => import('@/views/bbs/technology')
		}, {
			path: '/bbs/research',
			name: 'bbsResearch',
			meta: {
				title: '强敌研究'
			},
			component: () => import('@/views/bbs/research')
		}, {
			path: '/bbs/tactics',
			name: 'bbsTactics',
			meta: {
				title: '战法分析'
			},
			component: () => import('@/views/bbs/tactics')
		}, {
			path: '/bbs/military',
			name: 'bbsMilitary',
			meta: {
				title: '军情动态'
			},
			component: () => import('@/views/bbs/military')
		}, {
			path: '/bbs/:type/:id',
			name: 'bbsDetail',
			hidden: true,
			meta: {
				title: '详情',
				isDetail: true
			},
			component: () => import('@/views/bbs/detail')
		}]
	}, {
		path: '/guide',
		name: 'Guide',
		meta: {
			title: '工作指导'
		},
		redirect: '/guide/warduty',
		component: () => import('@/views/guide/index'),
		children: [{
			path: '/guide/warduty',
			name: 'guideWarduty',
			meta: {
				title: '战情部222'
			},
			component: () => import('@/views/guide/warduty')
		}, {
			path: '/guide/politics',
			name: 'guidePolitics',
			meta: {
				title: '政治工作处'
			},
			component: () => import('@/views/guide/politics')
		}, {
			path: '/guide/discipline',
			name: 'guideDiscipline',
			meta: {
				title: '纪律检查委员会'
			},
			component: () => import('@/views/guide/discipline')
		}, {
			path: '/guide/:type/:id',
			name: 'guideDetail',
			hidden: true,
			meta: {
				title: '详情',
				isDetail: true
			},
			component: () => import('@/views/guide/detail')
		}]
	}, {
		path: '/notice',
		name: 'Notice',
		meta: {
			title: '通知公告'
		},
		redirect: '/notice/list',
		component: () => import('@/views/common/router'),
		children: [{
			path: '/notice/list',
			name: 'noticeList',
			meta: {
				title: '通知公告列表'
			},
			component: () => import('@/views/notice/list')
		}, {
			path: '/notice/list/:id',
			name: 'noticeDetail',
			meta: {
				title: '通知公告详情'
			},
			component: () => import('@/views/notice/detail')
		}]
	}, {
		path: '/search',
		name: 'Search',
		meta: {
			title: '搜索结果'
		},
		component: () => import('@/views/search/index')
	}, {
		path: '/survey',
		name: 'Survey',
		meta: {
			title: '问卷调查',
			bgColor: '#f7f7f7'
		},
		component: () => import('@/views/survey/index')
	}, {
		path: '/article/:id',
		name: 'Article',
		meta: {
			title: '文章详情',
		},
		component: () => import('@/views/common/article')
	}, {
		path: '/statistics',
		name: 'Statistics',
		meta: {
			title: '投稿统计',
		},
		component: () => import('@/views/statistics/index')
	}, {
		path: '/meeting',
		name: 'Meeting',
		meta: {
			title: '学习贯彻党的二十届四中全会精神'
		},
		redirect: '/meeting/list',
		component: () => import('@/views/common/router'),
		children: [{
			path: '/meeting/list',
			name: 'meetingList',
			meta: {},
			component: () => import('@/views/meeting/list')
		}, {
			path: '/meeting/list/:id',
			name: 'meetingDetail',
			meta: {
				title: '学习贯彻党的二十届四中全会精神详情'
			},
			component: () => import('@/views/meeting/detail')
		}]
	}]
}]

const router = new VueRouter({
	routes
})
router.beforeEach((to, from, next) => {
	if (!!document.getElementsByClassName('layout_contain')[0]) {
		document.getElementsByClassName('layout_contain')[0].scrollTop = 0;
	}
	if (!to.matched.length) {
		next({
			path: '/404'
		});
		return false;
	}
	next();
})
export default router